package cn.ljy.mes.web.ws;

import cn.ljy.common.model.result.ResponseData;
import cn.ljy.mes.web.websocket.oauth.OauthSocketTest;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;

//@Api(tags = "后台信息推送模块")
//@RestController
//@RequestMapping(value = "/api/backstage/ws")
public class WebSocketController {

    @Autowired
    private OauthSocketTest oauthSocketTest;

    /**
     * 向所有用户推送消息
     * 说明：需要客户端连接上websocket
     * @return
     */
    @ApiOperation(value = "向所有用户推送消息",notes ="需要客户端连接上websocket才能接收")
    @GetMapping("/toAllUsers")
    @PreAuthorize("hasAuthority('ws:toAllUsers')")
    public ResponseData sendMessageOtAll(String message){
        oauthSocketTest.sendMessageToAll(message);
        return ResponseData.success(null);
    }


}
